var express = require('express');
var router = express.Router();
var mysql = require('mysql');
var connection = mysql.createConnection({
    host:'localhost',
    user:'localhost',
    password:'',
    database:'test'
});
connection.connect(function(err){
    if(err){
        console.log('err',err.stack);
    }
});
connection.query('select * from user',function(err,res,field){
    if(err){
        console.log('queryError',err);
    }else{
        //真实数据 res
        console.log('res',res);
    }
});


/* GET jade page. */
var allData = {
    title:'jade',
    book:{
        name:'javascript高级程序设计',
        price:73
    },
    texts:{
        text1:'实话实说寒山寺',
        text2:'速度快送快递圣诞快乐'
    },
    escaping:'hello <em>jade</em>',
    myName:'Jellen',
    classify:{
        yep:true,
        nop:false
    },
    books:[
        {
            name:'books1',
            price:12
        },
        {
            name:'books2',
            price:13
        },
        {
            name:'books3',
            price:14
        }
    ]
};

router.get('/', function(req, res, next) {
    res.render('jade', allData);
});
module.exports = router;
